home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / CALib & You… / Source / CALib / Implementation / UI / CAImage.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-07  |  4.6 KB  |  216 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CAImage.cpp
  3.  
  4.     Contains:    Container Application Library source
  5.  
  6.     Written by:    Tantek Çelik, Greg Ames, David Nelson, Steve Foley
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <8>     5/15/95    RB        Adding CA_CATCH
  13.          <7>     4/18/95    SJF        Fix CAGetCanvas - note that the graphics
  14.                                                     System is preset to kODQuickDraw which is
  15.                                                     probably uncool!
  16.          <5>     4/07/95    RB        Fixed some ref counting errors
  17.  
  18.          <4>     3/30/95    RB        Added routine CAForceUpdate().  Used by the app
  19.                                                      to force the update of a region, for scrolling.
  20.                                                      
  21.          <3+>     2/28/95    SJF        Add debug stuff to API calls
  22.          <3>     2/13/95    SJF        Interim checkin to update project database
  23.          <2)    12/15/94    SJF        change somGetGlobalEnvironment to _gpProxyShell->GetGlobalEnvironment
  24.          <1>    12/12/94    SJF            Fix up after adding TCAProxyShell stuff...
  25.          <0>    10/30/94    GCA,DHN    All mods to make project compile with no
  26.                                      errors under OpenDoc b1 (with SOM).
  27.          <_>      8/9/94    TÇ        first written
  28.          
  29.     To Do:
  30. */
  31.  
  32. #ifndef _CASESSN_
  33. #include "CASessn.h"
  34. #endif
  35.  
  36. #ifndef _CAERROR_
  37. #include "CAError.h"
  38. #endif
  39.  
  40. #ifndef _CADOCPRIV_
  41. #include "CADocPriv.h"
  42. #endif
  43.  
  44. #ifndef _CAFRMUTL_
  45. #include "CAFrmUtl.h"
  46. #endif
  47.  
  48. #ifndef SOM_ODFrame_xh
  49. #include <Frame.xh>
  50. #endif
  51.  
  52. #ifndef SOM_ODFacet_xh
  53. #include <Facet.xh>
  54. #endif
  55.  
  56. #ifndef SOM_ODShape_xh
  57. #include <Shape.xh>
  58. #endif
  59.  
  60. #ifndef SOM_ODTransform_xh
  61. #include <Trnsform.xh>
  62. #endif
  63.  
  64. #ifndef SOM_ODCanvas_xh
  65. #include <Canvas.xh>
  66. #endif
  67.  
  68. #ifndef _ODUTILS_
  69. #include <ODUtils.h>
  70. #endif
  71.  
  72. #ifndef SOM_ODWindow_xh
  73. #include <Window.xh>
  74. #endif
  75.  
  76. #ifndef _CAPROXYPARTDEF_
  77. #include "CAProxyPartDef.h"
  78. #endif
  79.  
  80. #ifndef CAProxyExtension_API
  81. #include "CAProxyExtension.xh"
  82. #endif
  83.  
  84. #ifndef SOM_ODFoci_xh
  85. #include <Foci.xh>
  86. #endif
  87.  
  88. #ifndef _TEMPOBJ_
  89. #include <TempObj.h>
  90. #endif
  91.  
  92. #pragma segment CALib
  93.  
  94.  
  95. //-------------------------------------------------------------------------
  96. // Imaging
  97. //-------------------------------------------------------------------------
  98.  
  99. pascal GrafPtr
  100. CAGetCanvas( CAVisFrame visFrame, CAGraphicsSystem graphicsSystem)
  101. {
  102.  
  103.     Environment*    ev = gCASession->GetEV();
  104.     ODCanvas*        canvas; 
  105.     
  106.     CA_TRY
  107.  
  108.         if (visFrame)
  109.         {
  110.             canvas = ((ODFacet*) visFrame)->GetCanvas(ev);
  111.             return (GrafPtr) canvas->GetPlatformCanvas(ev, (ODGraphicsSystem) graphicsSystem);
  112.         }
  113.         
  114.     CA_CATCH_ALL
  115.     CA_ENDTRY
  116.  
  117.     return NULL;
  118. }
  119.  
  120.  
  121. //-------------------------------------------------------------------------
  122.  
  123. pascal void
  124. CADrawFrame( CAVisFrame visFrame, RgnHandle invalidRgn )
  125. {
  126.     Environment*    ev            = gCASession->GetEV();
  127.     ODFacet*        facet        = (ODFacet*) visFrame;
  128.     ODShape*        invalShape    = kODNULL;
  129.     ODFacet*        rootFacet    = kODNULL;
  130.     
  131.     CA_TRY
  132.     
  133.         THROW_IF_NULL (facet);
  134.     
  135.         if (invalidRgn != NULL)
  136.         {
  137.             invalShape = facet->CreateShape (ev);
  138.             THROW_IF_NULL (invalShape);
  139.             invalShape->SetQDRegion (ev, invalidRgn);
  140.         }
  141.         else
  142.         {
  143.             invalShape = ODCopyAndRelease (ev, facet->AcquireClipShape (ev, kODNULL));
  144.         }
  145.         
  146.         //rootFacet = facet->GetContainingFacet(ev);
  147.         //TempODTransform xform = rootFacet->AcquireWindowFrameTransform(ev, kODNULL);
  148.         //invalShape->InverseTransform(ev, xform);
  149.  
  150.         //rootFacet = facet->GetContainingFacet(ev);
  151.         //TempODTransform wfXform = rootFacet->GetFrame(ev)->AcquireInternalTransform(ev, kODNULL);
  152.         //invalShape->Transform(ev, wfXform);
  153.  
  154.         //facet->Draw (ev, invalShape, kODNULL);
  155.         facet->Update (ev, invalShape, kODNULL);
  156.         
  157.     CA_CATCH_ALL
  158.     CA_ENDTRY
  159.     
  160.     ODFinalReleaseObject (ev, invalShape);
  161.     
  162. }
  163.  
  164. pascal void CADrawActiveBorder (void)
  165. {
  166.  
  167.     Environment*        ev            = gCASession->GetEV();
  168.     ODArbitrator*        arbitrator    = gCASession->GetArbitrator();;
  169.     
  170.     CA_TRY
  171.     
  172.         TempODFrame  tempFrame = arbitrator->AcquireFocusOwner (ev,
  173.             gCASession->GetODSession()->Tokenize(ev, kODSelectionFocus));
  174.             
  175.         if (tempFrame)
  176.             tempFrame->DrawActiveBorder (ev);
  177.         
  178.     CA_CATCH_ALL
  179.     CA_ENDTRY
  180.  
  181.  
  182. }
  183.  
  184. //-------------------------------------------------------------------------
  185.  
  186. pascal void
  187. CAInstallCanvasNotification( CACanvasUpdatedProc proc,
  188.                              CADocumentRef    document )
  189. {
  190.     Environment*        ev = gCASession->GetEV();
  191.     CAProxyExtension*    proxyExt = kODNULL;
  192.     
  193.     CA_TRY
  194.     
  195.         TempODPart tempPart = ((CADocument*)document)->AcquireRootPart();
  196.         THROW_IF_NULL (tempPart);
  197.         
  198.         proxyExt = (CAProxyExtension*)tempPart->AcquireExtension( ev, kCAProxyPartExtension );
  199.         THROW_IF_NULL (proxyExt);
  200.  
  201.         CACanvasUpdatedProcUPP canvasUpdatedUPPHandler;
  202.         
  203.         canvasUpdatedUPPHandler = (CACanvasUpdatedProcUPP) NewRoutineDescriptor((ProcPtr)proc, 
  204.                                                 uppCACanvasUpdatedProcInfo, 
  205.                                                 GetCurrentISA());
  206.  
  207.         proxyExt->InstallCACanvasUpdatedHandler( ev, canvasUpdatedUPPHandler);
  208.  
  209.     CA_CATCH_ALL
  210.     CA_ENDTRY
  211.     
  212.     ODReleaseObject (ev, proxyExt);
  213.  
  214.  
  215. }
  216.